package club.monkeywood.vo.buyer;

import club.monkeywood.enums.ResponseEnum;
import lombok.Data;

@Data
public class ServerResponseVO<T> {

    private int code;
    private String msg;
    private T data;

    private ServerResponseVO(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    private ServerResponseVO(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    private ServerResponseVO(int code) {
        this.code = code;
    }

    public static <T> ServerResponseVO<T> createBySuccess(){
        return new ServerResponseVO<T>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getDesc());
    }
    public static <T> ServerResponseVO<T> createBySuccessMessage(String msg){
        return new ServerResponseVO<T>(ResponseEnum.SUCCESS.getCode(),msg);
    }
    public static <T> ServerResponseVO<T> createBySuccess(T data){
        return new ServerResponseVO<T>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getDesc(), data);
    }
    public static <T> ServerResponseVO<T> createBySuccess(String msg, T data){
        return new ServerResponseVO<T>(ResponseEnum.SUCCESS.getCode(),msg,data);
    }

    public static <T> ServerResponseVO<T> createByError(){
        return new ServerResponseVO<T>(ResponseEnum.ERROR.getCode(), ResponseEnum.ERROR.getDesc());
    }

    public static <T> ServerResponseVO<T> createByErrorMessage(String msg){
        return new ServerResponseVO<T>(ResponseEnum.ERROR.getCode(),msg);
    }
    public static <T> ServerResponseVO<T> createByErrorCodeMessage(int code, String msg){
        return new ServerResponseVO<T>(code,msg);
    }

}
